package com.zsrt.java.day20161226.zzm.demo03;

import java.util.Scanner;

public class KongLingXing {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			System.out.println("请输入菱形上半部分的行数:");
			int row = sc.nextInt();
			test01(row);
			System.out.println("继续请按c,退出请按y");
			String temp = sc.next();
			if(temp.equals("y")){
				System.out.println("程序已经退出......");
				break;
			}
		}
		sc.close();
	}

	public static void test01(int row){
		for(int i=1;i<=row;i++){
			for(int k=1;k<=row-i;k++){
				System.out.print(" ");
			}
			for(int l=1;l<=2*i-1;l++){
				if(l==1||l==2*i-1){
					System.out.print("*");
				}else{
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		
		for(int i=row-1;i>=1;i--){
			for(int k=1;k<=row-i;k++){
				System.out.print(" ");
			}
			for(int l=2*i-1;l>=1;l--){
				if(l==1||l==2*i-1){
					System.out.print("*");
				}else{
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}
